﻿#if UNITY_EDITOR
using System.Collections.Generic;
using System.IO;
using UnityEditor;
/// <summary>
/// XLSX逻辑代码
/// </summary>
public partial class ESF_Logic
{
    #region BuildScriptCompilerResxTempleteEnum 生成脚本编译资源枚举    
    /// <summary>
    /// 生成脚本编译资源枚举
    /// </summary>
    public static void BuildScriptCompilerResxTempleteEnum()
    {
        string[] files = Directory.GetFiles(mResxTempleteEnumScript.directory, enESF_UnityFileExt.TextAsset.ESF_FirstAttribute<ESF_FileExtAttribute>().searchPattern);        
        if (files != null)
        {
            EditorUtility.DisplayProgressBar("BuildScriptCompilerResxTempleteEnum", "Start Build ResxTemplete Enum", 0);
            Dictionary<string, string> fileMap = new Dictionary<string, string>();
            string key = string.Empty;
            for (int i = 0; i < files.Length; i++)
            {
                key = Path.GetFileName(files[i]).ESF_OnlyCNUAndOtherReplaceU();
                fileMap.Add(key, files[i].ESF_TransPathSeparatorCharToUnityChar());
            }
            string code = File.ReadAllText(
                Path.Combine(mResxTempleteEnumScript.directory, 
                $"Compiler_ResxTempleteEnumScript{enESF_UnityFileExt.TextAsset.ESF_FirstAttribute<ESF_FileExtAttribute>().ext}")
                );
            code = code.CompilerCSharp(new { files = fileMap, enName= mResxTempleteEnumScript.fileName});            
            mResxTempleteEnumScript.SetText(code);
            mResxTempleteEnumScript.CreateAsset();
            ESF_P.ESF_Log(code);
            EditorUtility.DisplayProgressBar("BuildScriptCompilerResxTempleteEnum", "Build ResxTemplete Enum Success", 1);
            EditorUtility.ClearProgressBar();
            ESF_Utility.ExecuteMenuAssetsRefresh();
        }
    }
    #endregion
}
#endif
